package views.bill;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SpringLayout;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.border.BevelBorder;
import java.awt.Font;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.event.ActionListener;

public class Bill extends JPanel 
{
	private JTextField tfCustName;
	private JTextField tfCustPhone;
	private JButton btnAdd;
	private JTextField tfBarCode;
	private JTextField tfName;
	private JTextField tfQty;
	private JTextField tfMrp;
	private JTextField tfDiscount;
	private JTable table;
	private JTextField tfBillNo;
	private JTextField tfBillDate;
	private JTextField tfTime;
	private JTextField tfMcode;
	private JTextField tfSellPrice;
	private JTextField tfTotal;
	private JTextField tfPaidAmount;
	private JTextField tfBalance;
	private JTextField tfLbt;
	private JTextField tfVat;
	private JButton btnPrint;
	
	public Bill() 
	{
		setBackground(Color.ORANGE);
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
	
		setSize( 870, 655);
		
		JLabel lblBillNo = new JLabel("Bill No:");
		lblBillNo.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.WEST, lblBillNo, 30, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.NORTH, lblBillNo, 10, SpringLayout.NORTH, this);
		add(lblBillNo);
		
		tfBillNo = new JTextField();
		tfBillNo.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 10));
		springLayout.putConstraint(SpringLayout.NORTH, tfBillNo, 10, SpringLayout.NORTH,this);
		springLayout.putConstraint(SpringLayout.WEST, tfBillNo, 10, SpringLayout.EAST,lblBillNo);
		add(tfBillNo);
		tfBillNo.setColumns(5);
		
		JLabel lblBillDate = new JLabel("Bill Date:");
		lblBillDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblBillDate, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblBillDate, 30, SpringLayout.EAST,tfBillNo);
		add(lblBillDate);
		
		tfBillDate = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfBillDate, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, tfBillDate, 10, SpringLayout.EAST,lblBillDate);
		tfBillDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 10));
		tfBillDate.setColumns(5);
		add(tfBillDate);
		
		JLabel lblTime = new JLabel("Time:");
		lblTime.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblTime, 10, SpringLayout.NORTH,this);
		springLayout.putConstraint(SpringLayout.WEST, lblTime, 30, SpringLayout.EAST,tfBillDate);
		add(lblTime);
		
		tfTime = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfTime, 10, SpringLayout.NORTH,this);
		springLayout.putConstraint(SpringLayout.WEST, tfTime, 10, SpringLayout.EAST,lblTime);
		tfTime.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 10));
		tfTime.setColumns(5);
		add(tfTime);
		
		JLabel lblCustomerName = new JLabel("Customer Name");
		lblCustomerName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblCustomerName, 10, SpringLayout.SOUTH, lblBillNo);
		springLayout.putConstraint(SpringLayout.WEST, lblCustomerName, 30, SpringLayout.WEST, this);
		add(lblCustomerName);
		
		tfCustName = new JTextField();
		tfCustName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 11));
		springLayout.putConstraint(SpringLayout.NORTH, tfCustName, 6, SpringLayout.SOUTH, lblCustomerName);
		springLayout.putConstraint(SpringLayout.WEST, tfCustName, 30, SpringLayout.WEST,this);
		add(tfCustName);
		tfCustName.setColumns(20);
		
		JLabel lblCustomerPhone = new JLabel("Customer Phone");
		lblCustomerPhone.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblCustomerPhone, 0, SpringLayout.NORTH,lblCustomerName);
		springLayout.putConstraint(SpringLayout.WEST, lblCustomerPhone, 30, SpringLayout.EAST,tfCustName);
		add(lblCustomerPhone);
		
		tfCustPhone = new JTextField();
		tfCustPhone.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 11));
		springLayout.putConstraint(SpringLayout.WEST, tfCustPhone, 30, SpringLayout.EAST,tfCustName);
		springLayout.putConstraint(SpringLayout.NORTH, tfCustPhone, 0, SpringLayout.NORTH,tfCustName);
		add(tfCustPhone);
		tfCustPhone.setColumns(20);
		
		JLabel lblTotal = new JLabel("Total");
		lblTotal.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblTotal, 0, SpringLayout.NORTH,lblCustomerPhone);
		springLayout.putConstraint(SpringLayout.WEST, lblTotal, 20, SpringLayout.EAST,tfCustPhone);
		add(lblTotal);
		
		tfTotal = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfTotal, 0, SpringLayout.NORTH, tfCustPhone);
		springLayout.putConstraint(SpringLayout.WEST, tfTotal, 0, SpringLayout.WEST,lblTotal);
		add(tfTotal);
		tfTotal.setColumns(10);
		tfTotal.setEditable(false);
		
		JSeparator separator = new JSeparator();
		springLayout.putConstraint(SpringLayout.NORTH, separator, 10, SpringLayout.SOUTH,tfCustName );
		springLayout.putConstraint(SpringLayout.WEST, separator, 30, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, separator, -30, SpringLayout.EAST, this);
		add(separator);
		
		//*********************************************************************************
		
		JLabel lblBarcode = new JLabel("Barcode");
		lblBarcode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblBarcode, 5, SpringLayout.SOUTH, separator);
		springLayout.putConstraint(SpringLayout.WEST, lblBarcode, 0, SpringLayout.WEST, separator);
		add(lblBarcode);
		
		tfBarCode = new JTextField();
		tfBarCode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.WEST, tfBarCode, 30, SpringLayout.WEST,this);
		springLayout.putConstraint(SpringLayout.NORTH, tfBarCode, 5, SpringLayout.SOUTH, lblBarcode);
		add(tfBarCode);
		tfBarCode.setColumns(10);
		
		JLabel lblMcode = new JLabel("M Code");
		lblMcode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblMcode, 5, SpringLayout.SOUTH,tfBarCode);
		springLayout.putConstraint(SpringLayout.WEST, lblMcode, 30, SpringLayout.WEST,this);
		add(lblMcode);
		
		tfMcode = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfMcode, 5, SpringLayout.SOUTH, lblMcode);
		springLayout.putConstraint(SpringLayout.WEST, tfMcode, 0, SpringLayout.WEST,tfBarCode);
		tfMcode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		tfMcode.setColumns(10);
		add(tfMcode);
		
		JLabel lblName = new JLabel("Catgory Name");
		lblName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblName, 5, SpringLayout.SOUTH, tfMcode);
		springLayout.putConstraint(SpringLayout.WEST, lblName, 30, SpringLayout.WEST, this);
		add(lblName);
		
		tfName = new JTextField();
		tfName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfName, 5, SpringLayout.SOUTH, lblName);
		springLayout.putConstraint(SpringLayout.WEST, tfName, 30, SpringLayout.WEST, this);
		add(tfName);
		tfName.setColumns(10);
		
		JLabel lblQty = new JLabel("Quantity");
		lblQty.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblQty, 5, SpringLayout.SOUTH,tfName);
		springLayout.putConstraint(SpringLayout.WEST, lblQty, 30, SpringLayout.WEST,this);
		add(lblQty);
		
		tfQty = new JTextField();
		tfQty.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfQty, 5, SpringLayout.SOUTH, lblQty);
		springLayout.putConstraint(SpringLayout.WEST, tfQty, 30, SpringLayout.WEST, this);
		add(tfQty);
		tfQty.setColumns(10);
		
		JLabel lblMrp = new JLabel("M.R.P.");
		lblMrp.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblMrp, 5, SpringLayout.SOUTH, tfQty);
		springLayout.putConstraint(SpringLayout.WEST, lblMrp, 30, SpringLayout.WEST,this);
		add(lblMrp);
		
		tfMrp = new JTextField();
		tfMrp.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfMrp, 5, SpringLayout.SOUTH, lblMrp);
		springLayout.putConstraint(SpringLayout.WEST, tfMrp, 30, SpringLayout.WEST,this);
		add(tfMrp);
		tfMrp.setColumns(10);
		
		JLabel lblDiscount = new JLabel("Discount");
		lblDiscount.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblDiscount, 5, SpringLayout.SOUTH,tfMrp);
		springLayout.putConstraint(SpringLayout.WEST, lblDiscount, 30, SpringLayout.WEST,this);
		add(lblDiscount);
		
		tfDiscount = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tfDiscount, 5, SpringLayout.SOUTH,lblDiscount);
		tfDiscount.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.WEST, tfDiscount, 30, SpringLayout.WEST, this);
		add(tfDiscount);
		tfDiscount.setColumns(10);
		
		JLabel lblSellPrice = new JLabel("Sell Price");
		lblSellPrice.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblSellPrice, 5, SpringLayout.SOUTH,tfDiscount);
		springLayout.putConstraint(SpringLayout.WEST, lblSellPrice, 30, SpringLayout.WEST,this);
		add(lblSellPrice);
		
		tfSellPrice = new JTextField();
		tfSellPrice.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfSellPrice, 5, SpringLayout.SOUTH, lblSellPrice);
		springLayout.putConstraint(SpringLayout.WEST, tfSellPrice, 30, SpringLayout.WEST,this);
		add(tfSellPrice);
		tfSellPrice.setColumns(10);
		
		//*************************************************************************************
		JSeparator separator_1 = new JSeparator();
		springLayout.putConstraint(SpringLayout.NORTH, separator_1, 5, SpringLayout.SOUTH, separator);
		springLayout.putConstraint(SpringLayout.WEST, separator_1, 20, SpringLayout.EAST,tfBarCode);
		springLayout.putConstraint(SpringLayout.SOUTH, separator_1, -8, SpringLayout.SOUTH,this);
		separator_1.setOrientation(SwingConstants.VERTICAL);
		add(separator_1);
		
		JScrollPane panel = new JScrollPane();
		springLayout.putConstraint(SpringLayout.NORTH, panel, 8, SpringLayout.SOUTH, separator);
		springLayout.putConstraint(SpringLayout.WEST, panel, 20, SpringLayout.EAST, separator_1);
		springLayout.putConstraint(SpringLayout.SOUTH, panel, -20, SpringLayout.SOUTH, this);
		springLayout.putConstraint(SpringLayout.EAST, panel, -30, SpringLayout.EAST, this);
		add(panel);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Sr. No.", "MCODE", "CATAGORY", "M.R.P.", "DISCOUNT", "SELL PRICE", "QUANTITY", "TAX", "AMOUNT", "REMOVE"
			}
		));
		panel.setViewportView(table);
		
		btnPrint = new JButton("Print");
		btnPrint.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, btnPrint, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.EAST, btnPrint, -10, SpringLayout.EAST, this);
		add(btnPrint);
		
		JLabel lblPaidAmount = new JLabel("Paid Amount");
		lblPaidAmount.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblPaidAmount, 0, SpringLayout.NORTH, lblCustomerName);
		springLayout.putConstraint(SpringLayout.WEST, lblPaidAmount,20, SpringLayout.EAST,tfTotal);
		add(lblPaidAmount);
		
		tfPaidAmount = new JTextField();
		tfPaidAmount.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 11));
		springLayout.putConstraint(SpringLayout.NORTH, tfPaidAmount, 6, SpringLayout.SOUTH, lblPaidAmount);
		springLayout.putConstraint(SpringLayout.WEST, tfPaidAmount, 0, SpringLayout.WEST,lblPaidAmount);
		add(tfPaidAmount);
		tfPaidAmount.setColumns(10);
		
		
		JLabel lblBalance = new JLabel("Balance");
		lblBalance.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblBalance, 0, SpringLayout.NORTH, lblCustomerName);
		springLayout.putConstraint(SpringLayout.WEST, lblBalance, 20, SpringLayout.EAST,tfPaidAmount);
		add(lblBalance);
	
		
		tfBalance = new JTextField();
		tfBalance.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 11));
		springLayout.putConstraint(SpringLayout.NORTH, tfBalance, 0, SpringLayout.NORTH, tfPaidAmount);
		springLayout.putConstraint(SpringLayout.WEST, tfBalance, 0, SpringLayout.WEST, lblBalance);
		add(tfBalance);
		tfBalance.setColumns(10);
		tfBalance.setEditable(false);
		
		JLabel lblLbt = new JLabel("LBT");
		lblLbt.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblLbt, 5, SpringLayout.SOUTH, tfSellPrice);
		springLayout.putConstraint(SpringLayout.WEST, lblLbt, 0, SpringLayout.WEST, lblBillNo);
		add(lblLbt);
		
		tfLbt = new JTextField();
		tfLbt.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfLbt, 5, SpringLayout.SOUTH, lblLbt);
		springLayout.putConstraint(SpringLayout.WEST, tfLbt, 0, SpringLayout.WEST, lblBillNo);
		add(tfLbt);
		tfLbt.setColumns(10);
		
		JLabel lblVat = new JLabel("VAT");
		lblVat.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblVat, 5, SpringLayout.SOUTH, tfLbt);
		springLayout.putConstraint(SpringLayout.WEST, lblVat, 0, SpringLayout.WEST, lblBillNo);
		add(lblVat);
		
		tfVat = new JTextField();
		tfVat.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfVat, 5, SpringLayout.SOUTH, lblVat);
		springLayout.putConstraint(SpringLayout.WEST, tfVat, 0, SpringLayout.WEST, lblBillNo);
		add(tfVat);
		tfVat.setColumns(10);
		
		btnAdd = new JButton("ADD");
		
		springLayout.putConstraint(SpringLayout.WEST, btnAdd, 55, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, btnAdd,-10, SpringLayout.SOUTH,this);
		btnAdd.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		add(btnAdd);
	
	}

	public JTextField getTfCustName() {
		return tfCustName;
	}

	public void setTfCustName(JTextField tfCustName) {
		this.tfCustName = tfCustName;
	}

	public JTextField getTfCustPhone() {
		return tfCustPhone;
	}

	public void setTfCustPhone(JTextField tfCustPhone) {
		this.tfCustPhone = tfCustPhone;
	}

	public JButton getBtnAdd() {
		return btnAdd;
	}

	public void setBtnAdd(JButton btnAdd) {
		this.btnAdd = btnAdd;
	}

	public JTextField getTfBarCode() {
		return tfBarCode;
	}

	public void setTfBarCode(JTextField tfBarCode) {
		this.tfBarCode = tfBarCode;
	}

	public JTextField getTfName() {
		return tfName;
	}

	public void setTfName(JTextField tfName) {
		this.tfName = tfName;
	}

	public JTextField getTfQty() {
		return tfQty;
	}

	public void setTfQty(JTextField tfQty) {
		this.tfQty = tfQty;
	}

	public JTextField getTfMrp() {
		return tfMrp;
	}

	public void setTfMrp(JTextField tfMrp) {
		this.tfMrp = tfMrp;
	}

	public JTextField getTfDiscount() {
		return tfDiscount;
	}

	public void setTfDiscount(JTextField tfDiscount) {
		this.tfDiscount = tfDiscount;
	}

	public JTable getTable() {
		return table;
	}

	public void setTable(JTable table) {
		this.table = table;
	}

	public JTextField getTfBillNo() {
		return tfBillNo;
	}

	public void setTfBillNo(JTextField tfBillNo) {
		this.tfBillNo = tfBillNo;
	}

	public JTextField getTfBillDate() {
		return tfBillDate;
	}

	public void setTfBillDate(JTextField tfBillDate) {
		this.tfBillDate = tfBillDate;
	}

	public JTextField getTfTime() {
		return tfTime;
	}

	public void setTfTime(JTextField tfTime) {
		this.tfTime = tfTime;
	}

	public JTextField getTfMcode() {
		return tfMcode;
	}

	public void setTfMcode(JTextField tfMcode) {
		this.tfMcode = tfMcode;
	}

	public JTextField getTfSellPrice() {
		return tfSellPrice;
	}

	public void setTfSellPrice(JTextField tfSellPrice) {
		this.tfSellPrice = tfSellPrice;
	}

	public JTextField getTfTotal() {
		return tfTotal;
	}

	public void setTfTotal(JTextField tfTotal) {
		this.tfTotal = tfTotal;
	}

	public JTextField getTfPaidAmount() {
		return tfPaidAmount;
	}

	public void setTfPaidAmount(JTextField tfPaidAmount) {
		this.tfPaidAmount = tfPaidAmount;
	}

	public JTextField getTfBalance() {
		return tfBalance;
	}

	public void setTfBalance(JTextField tfBalance) {
		this.tfBalance = tfBalance;
	}

	public JTextField getTfLbt() {
		return tfLbt;
	}

	public void setTfLbt(JTextField tfLbt) {
		this.tfLbt = tfLbt;
	}

	public JTextField getTfVat() {
		return tfVat;
	}

	public void setTfVat(JTextField tfVat) {
		this.tfVat = tfVat;
	}
	
	public void actionListeners(ActionListener al)
	{
		btnAdd.addActionListener(al);
		btnPrint.addActionListener(al);
	}
	
}
